#include <QtTest>
#include "serverconfig.h"

class Test : public QObject
{
    Q_OBJECT

public:
    Test() = default;
    ~Test() = default;

private slots:
    void serverConfig_defaultValue();
    void serverConfig_setAnonymousEnable();
    void serverConfig_addUser();
    void serverConfig_setRootDirectory();
};

void Test::serverConfig_defaultValue()
{
    ServerConfig config;
    QCOMPARE(config.anonymousEnable(), true);
    QCOMPARE(config.rootDirectory(), QString(""));
}

void Test::serverConfig_setAnonymousEnable()
{
    ServerConfig config;
    QCOMPARE(config.anonymousEnable(), true);
    config.setAnonymousEnable(false);
    QCOMPARE(config.anonymousEnable(), false);
    config.setAnonymousEnable(true);
    QCOMPARE(config.anonymousEnable(), true);
}

void Test::serverConfig_addUser()
{
    ServerConfig config;
    QCOMPARE(config.verifyUser("test", "123"), false);
    config.addUser("test", "123");
    QCOMPARE(config.verifyUser("test", "123"), true);
}

void Test::serverConfig_setRootDirectory()
{
    ServerConfig config;
    QCOMPARE(config.rootDirectory(), QString(""));
    config.setRootDirectory("/test/dir");
    QCOMPARE(config.rootDirectory(), QString("/test/dir"));
}

QTEST_MAIN(Test)

#include "test.moc"
